//
//  TJPaymentDetailHeaderView.m
//  Teleport
//
//  Created by xtjun on 2020/6/16.
//  Copyright © 2020 xtjun. All rights reserved.
//

#import "TJPaymentDetailHeaderView.h"

@interface TJPaymentDetailHeaderView()

@property (weak, nonatomic) UILabel *titleLabel;
@property (weak, nonatomic) UILabel *subTitleLabel;

@property (strong, nonatomic) NSDateFormatter *formatter;


@end


@implementation TJPaymentDetailHeaderView 


- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        _formatter = [[NSDateFormatter alloc] init];
        [_formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        
        UILabel *titleLabel = [UILabel lableWithSuperView:self font:MediumFont(24) color:UIColor_Hex(0x3881E8) title:@"" textAlignment:NSTextAlignmentCenter];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(25 + KNavBarHight);
            make.centerX.offset(0);
        }];
        
        UILabel *stateLabel = [UILabel lableWithSuperView:self font:UIFont_Px(13) color:UIColor_Hex(0x272727) title:@"" textAlignment:NSTextAlignmentCenter];
        [stateLabel shearRoundedCornersWithRadiu:14];
        stateLabel.backgroundColor = UIColor_Hex(0xdae5f8);
        [stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(titleLabel.mas_bottom).offset(8);
            make.centerX.offset(0);
            make.height.offset(28);
            make.width.offset(60);
        }];
        
        UILabel *subTitleLabel = [UILabel lableWithSuperView:self font:UIFont_Px(13) color:UIColor_Hex(0x262626) title:@"" textAlignment:NSTextAlignmentCenter];
        [subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(stateLabel.mas_bottom).offset(18);
            make.centerX.offset(0);
        }];
        
        
        _stateLabel = stateLabel;
        _subTitleLabel = subTitleLabel;
        _titleLabel = titleLabel;
        
    }
    return self;
}

- (void)setModel:(TJPaymentDetailModel *)model {
    _model = model;
    
    _titleLabel.text  = [NSString stringWithFormat:@"¥%@", model.totalPrice];
    _subTitleLabel.text = [NSString stringWithFormat:@"打开你本人的%@，向收款人付款".localizedString,[self payType]];
}

- (NSString *)payType {
  
    if ([_model.payType isEqualToString:@"ALIAY"]) {
           return @"支付宝".localizedString;
       }else if ([_model.payType isEqualToString:@"BANKCARD"]) {
          return @"银行卡".localizedString;
       }else if ([_model.payType isEqualToString:@"WECHAT"]) {
           return @"微信".localizedString;
       }else{//没有
       
               return @"";

       }
}



@end
